<template>
	<view class="content">
		<view>buildList中下标为2的数据取楼盘数据名称字段：{{buildName}}</view>
		<view>
			<view>楼盘列表</view>
			<view class="build-list">
				<view class="build-item" @click="goToPage('/pages/index/details?id='+item.id)"
					v-for="(item,index) in buildList" :key="index">
					<view>楼盘名称：{{item.name}}</view>
					<view>户型：{{item.model.name}}</view>
					<view>
						<image :src="item.thumb"></image>
					</view>
					<view>创建时间:{{item.create_time}}</view>
				</view>
			</view>
		</view>
		<view>工地实景列表</view>
		<view class="build-list">
			<view class="build-item" v-for="(item,index) in constructionList" :key="index">
				<view>楼盘名称:{{item.name}}</view>
				<view>
					<image :src="item.thumb"></image>
				</view>
				<view>创建时间:{{item.create_time}}</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				buildName: "",
				buildList: [],
				constructionList: []
			}
		},
		onLoad() {
			this.getRequest();
		},
		onShow() {

		},
		methods: {
			goToPage(path) {
				uni.navigateTo({
					url: path
				})
			},
			getRequest() {
				// var then=this
				// uni.request({
				// 	method:'POST',
				// 	url:'https://baiyi.kent.work/api/v1/system/getIndexData',
				// 	success(res) {
				// 		console.log(res)
				// 		//获取buildlist
				// 		this.buildName=res.data.data.buildList[2].name
				// 		then.buildList=res.data.data.buildList;
				// 		then.constructionList=res.data.data.constructionList
				// 	},
				// 	fail() {

				// 	},
				// 	complete() {

				// 	}
				// })
				this.$http.post("/system/getIndexData", {}).then(res => {
					console.log(res)
					this.buildName=res.data.data.buildList[2].name
					this.buildList = res.data.data.buildList;
					this.constructionList = res.data.data.constructionList
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>